﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Mapping;

namespace Managistics.Model.Mappings
{
    public class SaleOrderMap : ClassMap<SaleOrder>
    {

        public SaleOrderMap()
        {
            Schema(Constants._tblSchema);
            Table(Constants._tblOrderCustomer);
            LazyLoad();

            Id(x => x.Orderid).GeneratedBy.Assigned().Column("ORDERID_C");
            References(x => x.Customer).Column("CUSTOMERID");
            References(x => x.Employee).Column("EMPLOYEEID");
            Map(x => x.Orderdate).Column("ORDERDATE").Not.Nullable();
            Map(x => x.Requestdate).Column("REQUESTDATE").Not.Nullable();
            Map(x => x.ShippingDate).Column("SHIPPING_DATE").Not.Nullable();
            Map(x => x.ShipAddress).Column("SHIP_ADDRESS").Not.Nullable().Length(250);
            Map(x => x.Status).Column("STATUS_C");
            Map(x => x.Note).Column("NOTE_C").Length(200);
            Map(x => x.PayCondition).Column("PAY_CONDITION_C").Length(50);
            Map(x => x.CompleteDate).Column("COMPLETE_DATE_CO");
            Map(x => x.TypeVat).Column("TYPE_VAT");
            Map(x => x.Confirmnote).Column("ConfirmNote").Length(4000);
            Map(x => x.Contactname).Column("ContactName").Length(4000);
            Map(x => x.Typeorder).Column("TypeOrder");
            Map(x => x.Title).Column("Title").Length(4000);
            Map(x => x.NumOutput).Column("num_output").Not.Nullable().Precision(5);
            Map(x => x.NumReturn).Column("num_return").Not.Nullable().Precision(5);

            HasMany(x => x.SaleOrderDetail).KeyColumn("ORDERID").Inverse().Not.LazyLoad();
        }
    }
}
